package com.jokul.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

/**
 * 使用MD5和base64进行加密
 * @author jokul
 * @date 2013-3-29
 * @time 下午4:03:23
 */
public class MD5 {

	public static String getMD5(String source) {
		String result = null;
		try {
			MessageDigest digest = MessageDigest.getInstance("MD5");
			BASE64Encoder base64e = new BASE64Encoder();

			result = base64e.encode(digest.digest(source.getBytes()));
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}

		return result;
	}
}
